using System;
using System.Runtime.Serialization;

namespace Source.Common
{
    public interface IUser
    {
        int UserId { get; set; }
        int DefaultCurrencyId { get; set; }
        string FirstName { get; set; }
        string LastName { get; set; }
        string Upi { get; set; }
        string Email { get; set; }
        string DateFormat { get; set; }

        string GetDateFormatOrFallBackToDefault();
    }

    [Serializable]
    [DataContract]
    public class UserDto : IUser
    {
        [DataMember]
        public int UserId
        { get; set; }

        [DataMember]
        public string FirstName
        { get; set; }

        [DataMember]
        public string LastName
        { get; set; }

        [DataMember]
        public string Upi
        { get; set; }

        [DataMember]
        public int DefaultCurrencyId
        { get; set; }

        [DataMember]
        public string Email
        { get; set; }

        [DataMember]
        public string DateFormat
        { get; set; }
        public const string IdentifierSeparator = "_$_";

        public string Fullname
        {
            get
            {
                return FirstName + " " + LastName;
            }
        }

        public string FullIdentifier
        {
            get
            {
                return Email + IdentifierSeparator + Upi;
            }
        }

        public string GetDateFormatOrFallBackToDefault()
        {
            if (!string.IsNullOrEmpty(DateFormat))
            {
                return DateFormat;
            }

            return GlobalConstants.supportedDateTimeFormats[0];
        }
       
    }
}